clf 

m = linspace(0.0001, 0.999, 400);

%prior that state is good


muVec = [0.1, 0.5, 0.9];

for i = 1:numel(muVec)

    mu = muVec(i);

    %Signal variances (should have sigma < tau)
    sigma = 0.5;       % "low" cost type
    tau = 1;         % "high" cost type
    
    gamma = - (mu/(1-mu)) .* (m./(m-1));
    
    pG = 1 - normcdf(-1/(2*sigma) - sigma * log(gamma));
    pB = 1 - normcdf(1/(2*sigma) - sigma * log(gamma));
    p = mu*pG + (1-mu)*pB;
    
    gammaA = mu*pG ./ (mu*pG + (1 - mu)*pB);
    gammaR = mu*(1 - pG) ./ (mu*(1 - pG) + (1 - mu)*(1 - pB));
    
    
    qG = 1 - normcdf(-1/(2*tau) - tau * log(gamma));
    qB = 1 - normcdf(1/(2*tau) - tau * log(gamma));
    q = mu*qG + (1-mu)*qB;
    
    deltaA = mu*qG ./ (mu*qG + (1 - mu)*qB);
    deltaR = mu*(1 - qG) ./ (mu*(1 - qG) + (1 - mu)*(1 - qB));
    
    
    
    f = q./(p+q);
    
    
    %hold on
    %plot(m,f, 'k')
    %plot(m,q, 'r')
    %plot(m,p, 'g')
    %plot(m,gammaA, 'ro')
    %plot(m,deltaA, 'go')
    %plot(m,exPostRegret, 'ko')
    %hold off


    L=plot(m,p,'r',m, q ,'b--',m,f,'k');

    set(L(1),'LineWidth',2);
    set(L(2),'LineWidth',2);
    set(L(3),'LineWidth',4);

    xlabel('Incentive m');
    ylabel('Participation probability');
    plotname1=['\sigma = ' num2str(sigma)];
    plotname2=['\sigma = ' num2str(tau)];
    legend(plotname1,plotname2,'P(cost = high | participate)');
    if mu > 0.55
        legend('Location','southeast');
    else
        legend('Location','northwest');
    end
    prior=mu*100;
    filename=['../graphs/supplyNormalExo' num2str(prior) '.pdf'];
    saveas(gcf,filename); 
   
    

    L=plot( m, gammaA       ,'r' , ...
            m, deltaA       ,'b--', ...
            m, gammaR       ,'r' , ...
            m, deltaR       ,'b--' ...
            );

    set(L(1),'LineWidth',2);
    set(L(2),'LineWidth',2);
    set(L(3),'LineWidth',2);
    set(L(4),'LineWidth',2);

    xlabel('Incentive m');
    ylabel('P(s = G | action)');
    plotname1=['\sigma = ' num2str(sigma)];
    plotname3=['\sigma = ' num2str(tau)];
    legend(plotname1,plotname3);
    if mu < 0.45
        legend('Location','northeast');
    else
        legend('Location','southwest');
    end
    prior=mu*100;
    filename=['../graphs/posteriorsNormalExo' num2str(prior) '.pdf'];
    saveas(gcf,filename); 

end


    